# _*_ coding: utf-8 _*_
# @Time     : 2022/7/23 16:47
# @Author   : dake
# @Email    : dake@2545923.com
# @File     : amend_page.py
# @Software : PyCharm
from selenium.webdriver.common.by import By
import unittest
from time import sleep
from pages.base_page import BasePage


class AmendPage(BasePage):
    """修改用户信息类"""
    photo_locator = (By.ID, "com.gfeng.daydaycook:id/imgv_icon")  # 头像
    sex_locator = (By.ID, "com.gfeng.daydaycook:id/rbt_boy")  # 性别
    username_locator = (By.ID, "com.gfeng.daydaycook:id/edt_nickname")  # 用户名
    intro_locator = (By.ID, "com.gfeng.daydaycook:id/edt_intro")  # 简介
    save_locator = (By.ID, "com.gfeng.daydaycook:id/rightButton")

    def ele_photo(self, x=500, y=170, x1=140, y1=90, x2=100,y2=100):
        """更换头像"""
        self.driver.find_element(*self.photo_locator).click()
        sleep(2)
        self.driver.tap([(x, y)])
        sleep(1)
        self.driver.tap([(x1, y1)])
        sleep(2)
        self.driver.tap([(x2, y2)])

    def ele_username(self, user):
        """修改用户名"""
        self.driver.find_element(*self.username_locator).click()
        sleep(1)
        self.driver.find_element(*self.username_locator).send_keys(user)
        sleep(1)

    def ele_sex(self):
        """选择性别"""
        self.driver.find_element(*self.sex_locator).click()

    def ele_intro(self, intro):
        """添加简介"""
        self.driver.find_element(*self.intro_locator).send_keys(intro)

    def ele_save(self):
        """点击保存"""
        self.driver.find_element(*self.save_locator).click()

    def ele_compile(self, user, intro):
        """总的"""
        self.driver.find_element(*self.username_locator).click()
        sleep(1)
        self.driver.find_element(*self.username_locator).send_keys(user)
        sleep(1)
        self.driver.find_element(*self.sex_locator).click()
        self.driver.find_element(*self.intro_locator).send_keys(intro)
        self.driver.find_element(*self.save_locator).click()